package cn.memset.sample;

import cn.memset.sample.classloaders.MyCommonClassLoader;

/**
 * Java中类的唯一性（命名空间）
 */
public class ClassNamespaceTest {
    private final static String COMMON_PATH = "D:\\anyuanwai\\common-sdk";
    public static void main(String[] args) throws Exception {
        MyCommonClassLoader l1 = new MyCommonClassLoader(COMMON_PATH);
        MyCommonClassLoader l2 = new MyCommonClassLoader(COMMON_PATH);

        String className = "cn.memset.app.entities.Employee";
        Class<?> c1 = Class.forName(className, false, l1);
        Class<?> c2 = Class.forName(className, false, l2);
        Object o1 = c1.newInstance();

        System.out.println("c1类型是否等于c2类型？" + c1.equals(c2));
        System.out.println("对象o1是否是c2类型？" + (c2.isInstance(o1)));
    }
}


